package cn.stylefeng.guns.modular.goodsCart.controller;

import cn.stylefeng.guns.base.pojo.page.LayuiPageInfo;
import cn.stylefeng.guns.modular.goodsCart.entity.TaoGoodCart;
import cn.stylefeng.guns.modular.goodsCart.model.params.TaoGoodCartParam;
import cn.stylefeng.guns.modular.goodsCart.model.result.TaoGoodCartResult;
import cn.stylefeng.guns.modular.goodsCart.service.TaoGoodCartService;
import cn.stylefeng.roses.core.base.controller.BaseController;
import cn.stylefeng.roses.core.reqres.response.ResponseData;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;
import java.util.Map;


/**
 * 购物车控制器
 *
 * @author lcw
 * @Date 2019-09-25 11:11:28
 */
@Controller
@RequestMapping("/taoGoodCart")
public class TaoGoodCartController extends BaseController {

    private String PREFIX = "/购物车/taoGoodCart";

    @Autowired
    private TaoGoodCartService taoGoodCartService;

    /**
     * 跳转到主页面
     *
     * @author lcw
     * @Date 2019-09-25
     */
    @RequestMapping("")
    public String index() {
        return PREFIX + "/taoGoodCart.html";
    }

    /**
     * 新增页面
     *
     * @author lcw
     * @Date 2019-09-25
     */
    @RequestMapping("/add")
    public String add() {
        return PREFIX + "/taoGoodCart_add.html";
    }

    /**
     * 编辑页面
     *
     * @author lcw
     * @Date 2019-09-25
     */
    @RequestMapping("/edit")
    public String edit() {
        return PREFIX + "/taoGoodCart_edit.html";
    }

    /**
     * 新增接口
     *
             * @author lcw
     * @Date 2019-09-25
            */
    @RequestMapping("/addItem")
    @ResponseBody
    public ResponseData addItem(TaoGoodCartParam taoGoodCartParam) {
        this.taoGoodCartService.add(taoGoodCartParam);
        return ResponseData.success();
    }

    /**
     * 编辑接口
     *
     * @author lcw
     * @Date 2019-09-25
     */
    @RequestMapping("/editItem")
    @ResponseBody
    public ResponseData editItem(TaoGoodCartParam taoGoodCartParam) {
        this.taoGoodCartService.update(taoGoodCartParam);
        return ResponseData.success();
    }

    /**
     * 删除接口
     *
     * @author lcw
     * @Date 2019-09-25
     */
    @RequestMapping("/delete")
    @ResponseBody
    public ResponseData delete(TaoGoodCartParam taoGoodCartParam) {
        this.taoGoodCartService.delete(taoGoodCartParam);
        return ResponseData.success();
    }

    /**
     * 查看详情接口
     *
     * @author lcw
     * @Date 2019-09-25
     */
    @RequestMapping("/detail")
    @ResponseBody
    public ResponseData detail(TaoGoodCartParam taoGoodCartParam) {
        TaoGoodCart detail = this.taoGoodCartService.getById(taoGoodCartParam.getId());
        return ResponseData.success(detail);
    }

    /**
     * 查询列表
     *
     * @author lcw
     * @Date 2019-09-25
     */
    @ResponseBody
    @RequestMapping("/list")
    public LayuiPageInfo list(TaoGoodCartParam taoGoodCartParam) {
        return this.taoGoodCartService.findPageBySpec(taoGoodCartParam);
    }



}


